package com.atwy.business.controller;

import com.atwy.business.service.BusinessService;
import com.atwy.common.RespBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class BusinessController {

    @Autowired
    BusinessService businessService;

    @PostMapping(value = "/seata/feign")
    public RespBean feign(String userId, String commodityCode, int orderCount) {
        try {
            businessService.purchase(userId, commodityCode, orderCount);
            return RespBean.ok("购买成功");
        } catch (Exception e) {
            e.printStackTrace();
            return RespBean.error("购买失败", e.getMessage());
        }
    }
}
